﻿/* 
 Copyright (C) 2011  Amblox Project

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

namespace Amblox.Game
{
    public class MessengerFriend
    {
        public Habbo Habbo;

        public bool Online
        {
            get
            {
                if (Habbo.Client == null)
                    return false;
                else
                    return Habbo.Client.CheckConnection;
            }
        }

        public MessengerFriend(Habbo Habbo)
        {
            this.Habbo = Habbo;
        }

        public FuseBuilder Serialize(bool Search)
        {
            FuseBuilder Buddy = new FuseBuilder();

            if (Search)
            {
                Buddy.AppendWired(Habbo.ID);
                Buddy.Append(Habbo.Name);
                Buddy.AppendBreak();
                Buddy.Append(Habbo.Motto);
                Buddy.AppendBreak();

                bool Online = this.Online;
                Buddy.AppendBoolean(Online);

                if (!Online)
                    Buddy.AppendBoolean(false);
                else
                    Buddy.AppendBoolean(false); // Habbo is in a room - Todo

                Buddy.AppendBreak();
                Buddy.AppendBoolean(false);
                Buddy.Append(Habbo.Look);
                Buddy.AppendBreak();
                Buddy.Append(""); // Habbo last online - Todo
                Buddy.AppendBreak();
                Buddy.AppendBreak();
            }
            else
            {
                Buddy.AppendWired(Habbo.ID);
                Buddy.Append(Habbo.Name);
                Buddy.AppendBreak();
                Buddy.AppendBoolean(true);
                bool Online = this.Online;
                Buddy.AppendBoolean(Online);
                
                if (!Online)
                    Buddy.AppendBoolean(false);
                else
                    Buddy.AppendBoolean(false); // Habbo is in a room - Todo

                Buddy.Append(Habbo.Look);
                Buddy.AppendBreak();
                Buddy.AppendBoolean(false);
                Buddy.Append(Habbo.Motto);
                Buddy.AppendBreak();
                Buddy.Append(""); // Habbo last online - Todo
                Buddy.AppendBreak();
                Buddy.AppendBreak();
            }

            return Buddy;
        }
    }
}
